package service

import (
	"io"
	"time"

	"gitee.com/Luna-CY/Golang-Project-Template/internal/interface/dao"

	"gitee.com/Luna-CY/Golang-Project-Template/internal/context"
	"gitee.com/Luna-CY/Golang-Project-Template/internal/errors"
	"gitee.com/Luna-CY/Golang-Project-Template/model"
)

// SystemStorage 存储服务接口
type SystemStorage interface {
	// PutObject 上传文件
	PutObject(ctx context.Context, filepath string, expired int64, async bool, file io.Reader) (*model.SystemObject, errors.Error)

	// DownloadObject 下载文件
	DownloadObject(ctx context.Context, object *model.SystemObject) (io.ReadCloser, errors.Error)

	// PreDeleteObject 预删除文件
	PreDeleteObject(ctx context.Context, object *model.SystemObject) errors.Error

	// DeleteObject 删除文件
	DeleteObject(ctx context.Context, object *model.SystemObject) errors.Error

	// GetObjectAccessedUrl 获取文件访问地址
	GetObjectAccessedUrl(ctx context.Context, object *model.SystemObject, timeout time.Duration) (string, errors.Error)

	// PersistenceObject 持久化对象
	PersistenceObject(ctx context.Context, object *model.SystemObject) errors.Error

	// CancelPersistenceObject 取消持久化
	CancelPersistenceObject(ctx context.Context, object *model.SystemObject) errors.Error

	// GetObjectByCondition 根据对象ID获取对象
	GetObjectByCondition(ctx context.Context, options ...dao.SystemObjectOption) (*model.SystemObject, errors.Error)

	// BatchGetObjectByCondition 根据对象ID批量获取对象
	BatchGetObjectByCondition(ctx context.Context, options ...dao.SystemObjectOption) ([]*model.SystemObject, errors.Error)

	// ListObjectByCondition 根据条件获取对象列表
	ListObjectByCondition(ctx context.Context, page int, size int, options ...dao.SystemObjectOption) (int64, []*model.SystemObject, errors.Error)
}
